package com.yl.googleplayer_yl.adapter;

import android.util.Log;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.yl.googleplayer_yl.R;
import com.yl.googleplayer_yl.global.MyApp;
import com.yl.googleplayer_yl.utils.ApiService;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/11/1 0001.
 */

public class HomePagerAdapter extends BasePagerAdapter {
    private static final String TAG = "HomePagerAdapter";

    public HomePagerAdapter(ArrayList<String> picUrls) {
        super(picUrls);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        String picUrl = picUrls.get(position);
         picUrl = ApiService.IMAGE_PREFIX + picUrl;
        Log.e(TAG, "instantiateItem: "+picUrl);
        ImageView imageView = new ImageView(MyApp.context);
        Glide
                .with(MyApp.context)
                .load(picUrl)
                .centerCrop()
                .placeholder(R.drawable.ic_launcher)
                .crossFade()
                .into(imageView);
        //Glide.with(MyApp.context).load(picUrl).into(imageView);
        container.addView(imageView);
        return imageView;
    }
}
